package app.com.business.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException;

import app.com.business.bo.AffectationDepartement;

import app.com.business.dao.AffectationDao;
import app.com.business.exceptions.MaterielException;

import com.groupeA.dao.impl.GenericDaoImpl;

public class AffectationDaoImpl extends GenericDaoImpl<AffectationDepartement, Long> implements AffectationDao{

	public AffectationDaoImpl() {
		super(AffectationDepartement.class);
	}

	public AffectationDepartement getAffectationByCodeAffectation(
			String affectationSelectionnee) throws MaterielException{
		try {
			List affectations =  getHibernateTemplate().find("from AffectationDepartement where codeAffectation = ?", affectationSelectionnee);
			if(affectations.size() == 0 | affectations == null | affectations.get(0) == null){
				throw new MaterielException();
			}
			return (AffectationDepartement)affectations.get(0) ;
			}catch(HibernateObjectRetrievalFailureException ex)
			{
				throw new MaterielException();
			}
		
	}
	
}
